/**
 * Created by zhuyufeng on 2016/1/1.
 */

var loudongStore = Ext.create('Ext.data.Store', {
	fields: ['loudong'],
	data : [
		{"loudong":"东1"},{"loudong":"东2"},{"loudong":"东3"},{"loudong":"东4"},
		{"loudong":"东5"},{"loudong":"东6"},{"loudong":"东7"},{"loudong":"东8"},
		{"loudong":"东9"},{"loudong":"东10"},{"loudong":"东11"},{"loudong":"东12"}
	]
});

var loudong = new Ext.form.ComboBox({
	fieldLabel: '请选择楼栋',
	store: loudongStore,
	valueField: 'loudong',
	tpl: Ext.create('Ext.XTemplate',
		'<tpl for=".">',
		'<div class="x-boundlist-item">{loudong}</div>',
		'</tpl>'
	),
	displayTpl: Ext.create('Ext.XTemplate', 		// template for the content inside text field
		'<tpl for=".">',
		'{loudong}',
		'</tpl>'
	)
});

Ext.define('analysisModel', {
	extend: 'Ext.data.Model',
	fields: [ 'date', 'count']
});
var analysisStore = Ext.create('Ext.data.Store', {
	storeId:'gridStore',
	model: 'analysisModel',
	autoLoad: true,
	pageSize: 4,
	proxy: {
		type: 'ajax',
		url : './json/history',
		reader: {
			type: 'json',
			root: 'rows',
			totalProperty: 'total'
		}
	}
});
var analysisgrid = Ext.create('Ext.grid.Panel', {
	store: analysisStore,
	height:410,
	forceFit:true,

	columns: [
		{text: '日期',width: 100,dataIndex: 'date'},
		{text: '数量',	width: 150,dataIndex: 'count'}
	],
	dockedItems:[{
		xtype:'pagingtoolbar',
		store:analysisStore,
		dock:'bottom',
		displayInfo:true,
		displayMsg:'第{0}条到第{1}条,一共{2}条',
		emptyMsg:'没有记录'
	}]
});

var analysisdata = new Ext.Panel({
	region:'center',
	split:false,
	border:true,
	collapsible:false,
	activeTab:0,
	autoHeight:true,
	title:'数据显示',
	items:[loudong,analysisgrid]
})

var analysis = new Ext.Panel({
	title:'数据分析',
	layout:'border',
	items:[analysisdata,chart]
})